package com.ianmoone.JZOF;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class S360Test3 {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		in.nextLine();
		int max = 0;
		String string = in.nextLine();
		String[] split = string.split(" ");
		List<Integer> A = new ArrayList<>();
		List<Integer> B = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			A.add(Integer.valueOf(split[i]));
		}
		string = in.nextLine();
		split = string.split(" ");
		for (int i = 0; i < n;) {
			int tmax = 0;
			int b = Integer.valueOf(split[i]);
			int indexA = A.indexOf(b);
			while(indexA>=0&&i<n&&A.get(indexA)==b){
				tmax++;
				indexA--;
				if (i<=n-1) {
					b = Integer.valueOf(split[++i]);
				}else {
					break;
				}
				
			}
			max = max>tmax?max:tmax;
			i+=tmax;
		}
		System.out.println(max);
	}
}
